package com.yunji.order.emuns;

import com.yunji.common.utils.bean.BeanUtils;

import java.util.Objects;

/**
 * @Project: yunji-coffee
 * @Package: com.yunji.order.emuns
 * @Title: ResultTypes
 * @Description: 结果类型
 * History:
 * Date						Version			Author			Summary
 * ========================================================================
 * 2024-04-30 17:59:25		V1.0			HuaAo		新建类
 */
public enum ResultTypes {
    FAILURE(0, "请求失败"),
    SUCCESS(1, "请求成功"),
    FINISH(2, "回调成功");

    private final Integer code;

    private final String text;

    ResultTypes(Integer code, String text) {
        this.code = code;
        this.text = text;
    }

    public Integer getCode() {
        return code;
    }

    public String getText() {
        return text;
    }

    public static String get(Integer code) {
        if (BeanUtils.isNull(code)) {
            return null;
        }
        ResultTypes[] enums = ResultTypes.values();
        for (ResultTypes e : enums) {
            if (Objects.equals(e.code, code)) {
                return e.text;
            }
        }
        return null;
    }
}